from selenium import webdriver
from selenium.webdriver.common.by import By

from pom.base import BaseDriver


class AdminMainPage(BaseDriver):
    def __init__(self, driver):
        super(AdminMainPage, self).__init__(driver)


    # 主页的已登录用户名
    _logined_username = By.XPATH, '//span[@class = "f-fs-18 f-vam username"]'

    # 退出按钮
    _quit_login = By.XPATH, '//li[@title = "退出登录"]'

    # 切换权限
    _switch_right = By.XPATH, '//li[@title="切换角色"]'

    # 已登录信息
    _login_info = By.XPATH, '//span[@class="f-fs-18 f-vam username"]'



    #首页
    _home_page = By.XPATH, '//li/span[text()="首页"]'

    # 题库管理
    _bank_manage = By.XPATH, '//span[text()="题库管理"]'

    # 实训题库
    _training_bank = By.XPATH, '//li[text()="实训题库"]'

    # 竞赛题库
    _competation_bank = By.XPATH, '//li[text()="竞赛题库"]'

    # 镜像管理
    _images_manage = By.XPATH, '//li//span[text()="镜像管理"]'

    # 竞赛管理
    _competation_manage = By.XPATH, '//span[text()="竞赛管理"]'

    # 竞赛列表
    _competation_list = By.XPATH, '//li[text()="竞赛列表"]'

    # 大屏设置
    _screen_setting = By.XPATH, '//li[text()="大屏设置"]'

    # 荣誉管理
    _honor_manage = By.XPATH, '//span[text()="荣誉管理"]'

    # 排行榜
    _rank_list = By.XPATH, '//span[text()="排行榜"]'

    # 留言互动
    _message_board = By.XPATH, '//span[text()="留言互动"]'

    # 权限管理
    _right_manage = By.XPATH, '//span[text()="权限管理"]'

    # 题库总数(需要返回页面元素的text)
    _question_bank_total = By.XPATH, '//div[text()="题库总数"]/div'

    # 竞赛题库总数（需要返回页面元素的text）
    _question_bank_competation = By.XPATH, '//div[contains(text(), "竞赛题库")]'

    js = 'document.getElementByXpath("//div[@id="chart-pie-total"]/div[2]").setAttribute("style","测试title")'

    # 实训题库总数（需要返回页面元素的text）
    _question_bank_training = By.XPATH, '//div[contains(text(), "实训题库")]'

    # 实训套题模块占比


    # 题目类型占比


    # 用户数


    # 实训套题答题次数


    # 勋章发放


    # 竞赛参与总人数

    @property
    def login_info(self):
        ele = self.find_ele(*self._login_info)
        self.logger.info("管理员 [登录名称]")
        return ele

    @property
    def quit_login(self):
        ele = self.find_ele(*self._quit_login)
        self.logger.info("管理员 [退出登录] 按钮")
        return ele

    @property
    def switch_right(self):
        ele = self.find_ele(*self._switch_right)
        self.logger.info("管理员 [切换权限] 按钮")
        return ele

    @property
    def username(self):
        return self.driver.find_element(*self._logined_username)

    # 跳转到首页
    @property
    def home_page(self):
        return self.driver.find_element(*self._home_page)

    # 跳转到实训题库
    @property
    def training_bank(self):
        self.driver.find_element(*self._bank_manage).click()
        return self.driver.find_element(*self._training_bank)

    # 跳转到竞赛题库
    @property
    def competation_bank(self):
        self.driver.find_element(*self._bank_manage).click()
        return self.driver.find_element(*self._competation_bank)

    # 跳转到镜像管理
    @property
    def images_manage(self):
        return self.driver.find_element(*self._images_manage)

    # 跳转到竞赛列表
    @property
    def competation_list(self):
        self.driver.find_element(*self._competation_manage).click()
        return self.driver.find_element(*self._competation_list)

    # 跳转到大屏设置
    @property
    def screen_setting(self):
        self.driver.find_element(*self._competation_manage)
        return self.driver.find_element(*self._screen_setting)

    # 跳转到荣誉管理
    @property
    def honor_manage(self):
        return self.driver.find_element(*self._honor_manage)

    # 跳转到排行榜
    @property
    def rank_list(self):
        return self.driver.find_element(*self._rank_list)

    # 跳转到留言互动
    @property
    def message_board(self):
        return self.driver.find_element(*self._message_board)

    # 跳转到权限管理
    @property
    def right_manage(self):
        return self.driver.find_element(*self._right_manage)